/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.company.teleporter.application;

import java.io.FileNotFoundException;

/**
 * Represent a folder containing data files
 * Use for synchronization
 * @author home
 */
public abstract class DataPath {

    private String name;
    private String path;

    /** 
     * @param name An application's state might depend on data files/folders in many places.<br>
     * When uploading this data file/folder, it will be saved under this path. Eg. \<b>name</b>\Data\data.config<br>
     * So be sure to have unique name for each DataPath per Application
     */
    public DataPath(String name) {
        this.name = name;
    }

    /** @see DataPath(String name) */
    public final String getName() {
        return name;
    }

    /** 
     * @return Absolute path to the folder in local disk <br>
     * Eg. C:\User\home\AppData\Roaming\AppName
     * @throws FileNotFoundException if the folder suppose to exist but can not be found
     */
    public final String getPath() throws FileNotFoundException {
        if (path != null) {
            return path;
        }

        return findPath();
    }

    /** 
     * Look for the file/folder with defaultPath, if can not find then perform a search to look for the directory
     * @throws FileNotFoundException if the folder suppose to exist but can not be found
     */
    protected String findPath() throws FileNotFoundException {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
    /** get default path depend on OS */
    protected abstract String getDefaultPath();
}
